

//---------------------------------------------------------------------------
// Copyright (c) 2011 Texas Instruments, Inc.
// This is an unpublished work created in the year stated above.
// Texas Instruments owns all rights in and to this work and
// intends to maintain and protect it as an unpublished copyright.
// In the event of either inadvertent or deliberate publication,
// the above stated date shall be treated as the year of first
// publication. In the evxfent of such publication, Texas Instruments
// intends to enforce its rights in the work under the copyright
// laws as a published work.
//----------------------------------------------------------------------------
// Filename                : message_protocol.c
//
// Functional Description  : SMS Messaging Protocol implementation 
//----------------------------------------------------------------------------

#include "message_protocol.h"

// Protocol Data (RAM)

unsigned int MsgAdminState = DEFAULT_MSG_ADMIN_STATE; 
unsigned int MsgAddrPtr = DEFAULT_MSG_ADDR_PTR;

// Protocol Data (FRAM)- Data saved to here and restored from here on reset

const unsigned int MsgAdminStateSaved = DEFAULT_MSG_ADMIN_STATE;

/*
 *  \fn void msg_protocol_init()
 *  \brief Initializes the application parameters by reading them from persistent memory and storing in RAM
 */
void msg_protocol_init()
{
	MsgAdminState = MsgAdminStateSaved;
	
	message_protocol_init_app();
}

/*
 * \fn void msg_protocol_save_parameters()
 * \brief Save application parameters into persistent memory
 */
void msg_protocol_save_parameters()
{
	*((unsigned int*)&MsgAdminStateSaved) = MsgAdminState;
	
	message_handler_application_save_parameters();
}

/*
 * \fn void msg_protocol_reset_defaults()
 * \brief Restore factory defaults.
 */
void msg_protocol_reset_defaults()
{
	MsgAdminState = DEFAULT_MSG_ADMIN_STATE;  
	
	message_handler_application_reset_defaults();
	
	msg_protocol_save_parameters();
}

